<template>
	<view>
		<!-- 选择卡 -->
		<view class="detail1">
			<view class="detail1-1" @click="show = true">
				<image src="../../static/img/nhlogo.png" mode=""></image>
				<text>6230****8471</text>
				<image src="../../static/img/xiaosanjiao.png" mode="" class="detail1-1img"></image>
				<u-select v-model="show" :list="list"></u-select>
			</view>
			<view class="detail1-2" @click="show1=true">
				<text>人民币 | 本币</text>
				<image src="../../static/img/xiaosanjiao.png" mode=""></image>
				<u-select v-model="show1" :list="list1"></u-select>
			</view>
		</view>
		<!-- 主体 -->
		<view class="detail2">
			<view class="detail2-1">
				<view :class="{'active': activeIndex === 0}" @click="handleClick(0)">
				      近一周
				    </view>
				    <view :class="{'active': activeIndex === 1}" @click="handleClick(1)">
				      近一月
				    </view>
				    <view :class="{'active': activeIndex === 2}" @click="handleClick(2)">
				      近三月
				    </view>
				    <view class="detail2-11" @click="gorefer">
				      筛选
				      <image src="../../static/img/xiaosanjiao.png" mode=""></image>
				    </view>
			</view>
			<view class="detail2-2">
				<view class="detail2-21">
					<view id="wzyamoney" v-for="(item,index) in list2" :key="index" @click="next(item.id)">
						<view class="sectionleft" >
							<view class="wwWeChat">项目：{{item.account}}</view>
							<view class="wwWeChat1">{{item.timee}}      {{item.specific}}</view>
						</view>
						<view class="wwsectionright">
							<view class="wwWeChat2">{{item.moneye}}元</view>
						</view>
					</view>
				</view>
			</view>
			<view class="detail2-3">
				<u-divider>没有更多了</u-divider>
			</view>
			
		</view>
		
	</view>
</template>

<script>
	// 引入接口
		import {
			detail,
			filter
		} from "../../API/detail.js"
	export default {
		data() {
			return {
				show: false,
				list: [{
					value: '1',
					label: '6230****8471'
				}],
				show1: false,
				list1: [{
					value: '1',
					label: '人民币 | 本币'
				}],
				list2:[],
				activeIndex: 0
			}
		},
		
		methods: {
			gorefer(){
				uni.navigateTo({
					url:"/pages/refer/refer"
				})
			},
			detail1(){
				detail().then((res)=>{
					// console.log(res);
					this.list2=res.data.data
				}).catch((err)=>{
					console.log(err);
				})
			},
			handleClick(index) {
			      this.activeIndex = index;
				   uni.request({
				  	          url: "http://172.16.105.51:8000/filterData",
				  	          method: "POST",
				  	          data: {
				  	            queryType: index,
				  	          },
				  	          header: {
				  	            "Content-Type": "application/json",
				  	          },
				  	          success: (res) => {
								  console.log(res);
				  	            this.list2 = res.data.data; // 假设结果的键为"serve"
				  	          },
				  	          fail: (error) => {
				  	            console.error("Error:", error);
				  	          },
				  	        });
			},
			// 接收筛选结果，并判断
			onLoad(option){
				// console.log(JSON.parse(option.createTime) );
				let a=typeof(option.createTime) == "undefined"
				if(a){
					// console.log(a);
					this.detail1()
				}else{
					this.list2=[]
					this.list2=JSON.parse(option.createTime) 
				}
			},
			next(s){
				uni.navigateTo({
					url:"/pages/detail/detail1?id="+s
				})
			}
		}
	}
</script>

<style>
	.detail1 {
		height: 110rpx;
		background-color: white;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 35rpx;
	}

	.detail1-1 text {
		margin-left: 20rpx;
	}

	.detail1-1 image:nth-child(1) {
		width: 50rpx;
		height: 50rpx;
	}

	.detail1-1img {
		width: 30rpx;
		height: 30rpx;
		margin-left: 20rpx;
	}

	.detail1-2 image {
		width: 30rpx;
		height: 30rpx;
		margin-right: 20rpx;
		margin-left: 10rpx;
	}

	.detail2 {
		height: 1450rpx;
		background-color: #f7f7f7;
	}

	.detail2-1 {
	  display: flex;
	  justify-content: space-evenly;
	}
	
	.detail2-1 view {
	  width: 140rpx;
	  height: 50rpx;
	  background-color: white;
	  border-radius: 30rpx;
	  text-align: center;
	  line-height: 50rpx;
	  margin-top: 20rpx;
	}
	
	.detail2-1 view.active {
	  background-color: orange;
	  color: white;
	}
	
	.detail2-11 image {
	  width: 30rpx;
	  height: 30rpx;
	}
	#wzyamoney {
	  height: 160rpx;
	  border-bottom: 1rpx solid rgb(160, 157, 157);
	  background-color: #ffffff;
	}
	.wwWeChat {
	  padding-top: 20rpx;
	  margin-left: 20rpx;
	}
	.wwWeChat2 {
	  margin-left: 340rpx;
	  margin-top: -78rpx;
	  color: rgb(255, 162, 0);
	}
	.wwWeChat1 {
	  margin-top: 40rpx;
	  margin-left: 20rpx;
	}
	.wwsectionright {
	  display: flex;
	  flex-direction: column;
	  margin-left: 260rpx;
	}
	.detail2-3{
		height: 80rpx;
		line-height: 80rpx;
	}
</style>